/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ibm.law.domain;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author shanch
 */
@Entity
@Table(name = "dictionary")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Dictionary.findAll", query = "SELECT d FROM Dictionary d"),
    @NamedQuery(name = "Dictionary.findById", query = "SELECT d FROM Dictionary d WHERE d.id = :id"),
    @NamedQuery(name = "Dictionary.findByName", query = "SELECT d FROM Dictionary d WHERE d.name = :name"),
    @NamedQuery(name = "Dictionary.findByCode", query = "SELECT d FROM Dictionary d WHERE d.code = :code"),
    @NamedQuery(name = "Dictionary.findBySeq", query = "SELECT d FROM Dictionary d WHERE d.seq = :seq")})

public class Dictionary   extends AbstractModelObject implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Column(name = "name")
    private String name;
    @Column(name = "code")
    private String code;
    @Column(name = "seq")
    private Integer seq;
    @OneToMany(mappedBy = "parent")
    private Collection<Dictionary> dictionaryCollection;
    @JoinColumn(name = "parent_id", referencedColumnName = "id")
    @ManyToOne
    private Dictionary parent;

    public Dictionary() {
    }

    public Dictionary(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
    	String oldValue=this.name;
        this.name = name;
        firePropertyChange("name", oldValue, name);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public Integer getSeq() {
        return seq;
    }

    public void setSeq(Integer seq) {
        this.seq = seq;
    }

    @XmlTransient
    public Collection<Dictionary> getDictionaryCollection() {
        return dictionaryCollection;
    }

    public void setDictionaryCollection(Collection<Dictionary> dictionaryCollection) {
        this.dictionaryCollection = dictionaryCollection;
    }

    public Dictionary getParent() {
        return parent;
    }

    public void setParent(Dictionary parent) {
        this.parent = parent;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Dictionary)) {
            return false;
        }
        Dictionary other = (Dictionary) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ibm.law.entity.Dictionary[ id=" + id + " ]";
    }
    
}
